﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

namespace OpenRPOSBackOffice
{
    public partial class EditMenuCategoryDialog : ChildWindow
    {
        public ServiceReferenceOpenRPOS.MenuCategory selectedMenuCategory;

        public EditMenuCategoryDialog()
        {
            InitializeComponent();
        }

        private async void btnOK_Click(object sender, RoutedEventArgs e)
        {
            // Update the name of this menu category
            selectedMenuCategory.col_Name = tbMenuCategoryName.Text.Trim();
            selectedMenuCategory.bFilterName = true;
            await Globals.db.UpdateMenuCategoryObject(selectedMenuCategory);
            // Re-init the display
            Globals.menuItems.initMenuCategories(true);
            Globals.menuItems.initMenuItems(true);
            this.DialogResult = true;
        }

        private void btnCancel_Click(object sender, RoutedEventArgs e)
        {
            this.DialogResult = false;
        }

        private void tbMenuCategoryName_KeyDown(object sender, KeyEventArgs e)
        {
            // Call the OK button handlers if "Enter" is pressed
            if (e.Key == Key.Enter)
                btnOK_Click(sender, e);
        }

    }
}

